import java.util.Arrays;
import java.util.List;

public class Client {
    public static void main(String[] args) throws InterruptedException {
        // 创建论文清单
        PaperList list0fRainy = new PaperList("Rainy", Arrays.asList(
                new Thesis("Reading"),
                new ConferencePaper("Science"),
                new JournalPaper("Technology"),
                new JournalPaper("Art")
        ));

        // 创建学生列表
        List<Student> students = Arrays.asList(
                new Student("Cloudy", 1, PaperType.Thesis),
                new Student("Sunny", 2, PaperType.JournalPaper),
                new Student("Windy", 1, PaperType.ConferencePaper)
        );

        // 多线程选择论文
        for (Student student : students) {
            new Thread(() -> {
                try {
                    List<Paper> selected = list0fRainy.selectPaper(student);
                    System.out.println(student.getName() + " 选择了: " + selected);
                } catch (NoEnoughPapersException | IllegalArgumentException e) {
                    System.err.println(e.getMessage());
                }
            }).start();
        }

        // 等待线程执行完成
        Thread.sleep(1000);
        System.out.println("最终选择结果:\n" + list0fRainy.getSelectionResult());
    }
}